glteximage2d - Man Page






glTexImage2D(3G)	       OpenGL Reference		      glTexImage2D(3G)



NAME
     glTexImage2D - specify a two-dimensional texture image


C SPECIFICATION
     void glTexImage2D(	GLenum target,
			GLint level,
			GLint components,
			GLsizei	width,
			GLsizei	height,
			GLint border,
			GLenum format,
			GLenum type,
			const GLvoid *pixels )


PARAMETERS
     target	 Specifies the target texture.	Must be	GL_TEXTURE_2D,
		 GL_PROXY_TEXTURE_2D_EXT, or GL_DETAIL_TEXTURE_2D_SGIS.

     level	 Specifies the level-of-detail number.	Level 0	is the base
		 image level.  Level n is the nth mipmap reduction image.

     components	 is used to request the	internal storage format	of the texture
		 image.	 It must be 1, 2, 3, or	4, or one of the following
		 symbolic constants:  GL_ALPHA,	GL_ALPHA4_EXT, GL_ALPHA8_EXT,
		 GL_ALPHA12_EXT, GL_ALPHA16_EXT, GL_LUMINANCE,
		 GL_LUMINANCE4_EXT, GL_LUMINANCE8_EXT, GL_LUMINANCE12_EXT,
		 GL_LUMINANCE16_EXT, GL_LUMINANCE_ALPHA,
		 GL_LUMINANCE4_ALPHA4_EXT, GL_LUMINANCE6_ALPHA2_EXT,
		 GL_LUMINANCE8_ALPHA8_EXT, GL_LUMINANCE12_ALPHA4_EXT,
		 GL_LUMINANCE12_ALPHA12_EXT, GL_LUMINANCE16_ALPHA16_EXT,
		 GL_INTENSITY_EXT, GL_INTENSITY4_EXT, GL_INTENSITY8_EXT,
		 GL_INTENSITY12_EXT, GL_INTENSITY16_EXT, GL_RGB, GL_RGB2_EXT,
		 GL_RGB4_EXT, GL_RGB5_EXT, GL_RGB8_EXT,	GL_RGB10_EXT,
		 GL_RGB12_EXT, GL_RGB16_EXT, GL_RGBA, GL_RGBA2_EXT,
		 GL_RGBA4_EXT, GL_RGB5_A1_EXT, GL_RGBA8_EXT, GL_RGB10_A2_EXT,
		 GL_RGBA12_EXT,	GL_RGBA16_EXT, GL_DEPTH_COMPONENT,
		 GL_DUAL_ALPHA4_SGIS, GL_DUAL_ALPHA8_SGIS,
		 GL_DUAL_ALPHA12_SGIS, GL_DUAL_ALPHA16_SGIS,
		 GL_DUAL_LUMINANCE4_SGIS, GL_DUAL_LUMINANCE8_SGIS,
		 GL_DUAL_LUMINANCE12_SGIS, GL_DUAL_LUMINANCE16_SGIS,
		 GL_DUAL_INTENSITY4_SGIS, GL_DUAL_INTENSITY8_SGIS,
		 GL_DUAL_INTENSITY12_SGIS, GL_DUAL_INTENSITY16_SGIS,
		 GL_DUAL_LUMINANCE_ALPHA4_SGIS,	GL_DUAL_LUMINANCE_ALPHA8_SGIS,
		 GL_QUAD_ALPHA4_SGIS, GL_QUAD_ALPHA8_SGIS,
		 GL_QUAD_LUMINANCE4_SGIS, GL_QUAD_LUMINANCE8_SGIS,
		 GL_QUAD_INTENSITY4_SGIS, or GL_QUAD_INTENSITY8_SGIS.

     width	 Specifies the width of	the texture image.  Must be
		 2**n+2*border for some	integer	n.




									Page 1






glTexImage2D(3G)	       OpenGL Reference		      glTexImage2D(3G)



     height	 Specifies the height of the texture image.  Must
		 2**m+I*border for some	integer	m, where I is 2	when
		 GL_INTERLACE_SGIX is disabled,	and 1 otherwise.

     border	 Specifies the width of	the border.  Must be either 0 or 1.

     format	 Specifies the format of the pixel data.  The following
		 symbolic values are accepted:	GL_COLOR_INDEX,	GL_RED,
		 GL_GREEN, GL_BLUE, GL_ALPHA, GL_RGB, GL_RGBA, GL_ABGR_EXT,
		 GL_LUMINANCE, GL_LUMINANCE_ALPHA, and GL_DEPTH_COMPONENT.

     type	 Specifies the data type of the	pixel data.  The following
		 symbolic values are accepted:	GL_UNSIGNED_BYTE, GL_BYTE,
		 GL_BITMAP, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT,
		 GL_INT, GL_FLOAT, GL_UNSIGNED_BYTE_3_3_2_EXT,
		 GL_UNSIGNED_SHORT_4_4_4_4_EXT,	GL_UNSIGNED_SHORT_5_5_5_1_EXT,
		 GL_UNSIGNED_INT_8_8_8_8_EXT, and
		 GL_UNSIGNED_INT_10_10_10_2_EXT.

     pixels	 Specifies a pointer to	the image data in memory.


DESCRIPTION
     Texturing maps a portion of a specified texture image onto	each graphical
     primitive for which texturing is enabled.	Two-dimensional	texturing is
     enabled and disabled using	glEnable and glDisable with argument
     GL_TEXTURE_2D.

     Texture images are	defined	with glTexImage2D. The arguments describe the
     parameters	of the texture image, such as height, width, width of the
     border, level-of-detail number (see glTexParameter), and the internal
     resolution	and format used	to store the image.  The last three arguments
     describe the way the image	is represented in memory, and they are
     identical to the pixel formats used for glDrawPixels.

     If	target is GL_PROXY_TEXTURE_2D_EXT no data is read from pixels,	but
     all of the	texture	image state is recalculated, checked for consistency,
     and checked against the implementation's capabilities.  If	the
     implementation cannot handle a texture of the requested texture size, it
     will set all of the texture image state to	0 (GL_TEXTURE_WIDTH,
     GL_TEXTURE_HEIGHT,	GL_TEXTURE_BORDER, GL_TEXTURE_COMPONENTS,
     GL_TEXTURE_RED_SIZE_EXT, GL_TEXTURE_GREEN_SIZE_EXT,
     GL_TEXTURE_BLUE_SIZE_EXT, GL_TEXTURE_ALPHA_SIZE_EXT,
     GL_TEXTURE_LUMINANCE_SIZE_EXT, and	GL_TEXTURE_INTENSITY_SIZE_EXT),	but no
     error will	be generated.

     If	target is GL_TEXTURE_2D	or GL_DETAIL_TEXTURE_2D_SGIS, data is read
     from pixels as a sequence of signed or unsigned bytes, shorts, or longs,
     or	single-precision floating-point	values,	depending on type. These
     values are	grouped	into sets of one, two, three, or four values,
     depending on format, to form elements. (Note that if type is set to
     GL_UNSIGNED_BYTE_3_3_2_EXT, GL_UNSIGNED_SHORT_4_4_4_4_EXT,



									Page 2






glTexImage2D(3G)	       OpenGL Reference		      glTexImage2D(3G)



     GL_UNSIGNED_SHORT_5_5_5_1_EXT, GL_UNSIGNED_INT_8_8_8_8_EXT, or
     GL_UNSIGNED_INT_10_10_10_2_EXT then it is a special case in which all the
     elements of each group are	packed into a single unsigned byte, unsigned
     short, or unsigned	int. This is described in glDrawPixels.)

     If	type is	GL_BITMAP, the data is considered as a string of unsigned
     bytes (and	format must be GL_COLOR_INDEX).	Each data byte is treated as
     eight 1-bit elements, with	bit ordering determined	by GL_UNPACK_LSB_FIRST
     (see glPixelStore).

     The first element corresponds to the lower-left corner of the texture
     image.  Subsequent	elements progress left-to-right	through	the remaining
     texels in the lowest row of the texture image, and	then in	successively
     higher rows of the	texture	image.	The final element corresponds to the
     upper-right corner	of the texture image.

     When GL_INTERLACE_SGIX is enabled,	only rows (0,2,4,...) of the texture
     image (where the border is	considered part	of the texture image) are
     defined.  Rows (1,3,5,...)	are left undefined and can only	be defined
     using glTexSubImage2DEXT or glCopyTexSubImage2DEXT.  Note,	that when
     GL_INTERLACE_SGIX is enabled the total height (i.e., the height of
     interior texture image plus twice the border) of the defined texture is
     2*height.

     Each element of pixels is converted to an RGBA element according to
     format, as	detailed below.	 Except	for GL_COLOR_INDEX, after the
     conversion	to RGBA, each component	is multiplied by the signed scale
     factor GL_c_SCALE,	added to the signed bias GL_c_BIAS, and	clamped	to the
     range [0,1], where	c is RED, GREEN, BLUE, or ALPHA, respectively (see
     glPixelTransfer).

     According to format, the conversion to RGBA is as follows:

     GL_COLOR_INDEX
	       Each element is a single	value, a color index. It is converted
	       to fixed	point (with an unspecified number of zero bits to the
	       right of	the binary point), shifted left	or right depending on
	       the value and sign of GL_INDEX_SHIFT, and added to
	       GL_INDEX_OFFSET (see glPixelTransfer). The resulting index is
	       converted to a set of color components using the
	       GL_PIXEL_MAP_I_TO_R, GL_PIXEL_MAP_I_TO_G, GL_PIXEL_MAP_I_TO_B,
	       and GL_PIXEL_MAP_I_TO_A tables, and clamped to the range	[0,1].

     GL_RED    Each element is a single	red component. It is converted to
	       floating	point and assembled into an RGBA element by attaching
	       0.0 for green and blue, and 1.0 for alpha.

     GL_GREEN  Each element is a single	green component. It is converted to
	       floating	point and assembled into an RGBA element by attaching
	       0.0 for red and blue, and 1.0 for alpha.





									Page 3






glTexImage2D(3G)	       OpenGL Reference		      glTexImage2D(3G)



     GL_BLUE   Each element is a single	blue component.	It is converted	to
	       floating	point and assembled into an RGBA element by attaching
	       0.0 for red and green, and 1.0 for alpha.

     GL_ALPHA  Each element is a single	alpha component. It is converted to
	       floating	point and assembled into an RGBA element by attaching
	       0.0 for red, green, and blue.

     GL_RGB    Each element is an RGB triple: first red, then green, and then
	       blue.  It is converted to floating point	and assembled into an
	       RGBA element by attaching 1.0 for alpha.

     GL_RGBA,

     GL_ABGR_EXT
	       Each element contains all four components; for GL_RGBA, the red
	       component is first, followed by green, then blue, and then
	       alpha; for GL_ABGR_EXT the order	is alpha, blue,	green, and
	       then red.

     GL_LUMINANCE
	       Each element is a single	luminance value.  It is	converted to
	       floating	point, then assembled into an RGBA element by
	       replicating the luminance value three times for red, green, and
	       blue and	attaching 1.0 for alpha.

     GL_LUMINANCE_ALPHA
	       Each element is a luminance/alpha pair.	It is converted	to
	       floating	point, then assembled into an RGBA element by
	       replicating the luminance value three times for red, green, and
	       blue.

     Please refer to the glDrawPixels reference	page for a description of the
     acceptable	values for the type parameter.

     An	application may	desire that the	texture	be stored at a certain
     resolution, or that it be stored in a certain format. This	resolution and
     format can	be requested by	components. The	GL will	choose an internal
     representation that closely approximates that requested by	components,
     but it may	not match exactly.  (The representations specified by
     GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, and GL_RGBA must	match exactly.
     The numeric values	1, 2, 3, and 4 may also	be used	to specify the above
     representations.)

     The GL_PROXY_TEXTURE_2D_EXT target	can be used to try out a particular
     resolution	and format.  The implementation	will compute its best match
     for the requested storage resolution and format. This state can then be
     queried using glGetTexLevelParameter.  If the texture cannot be
     accomodated texture state will be set to 0.






									Page 4






glTexImage2D(3G)	       OpenGL Reference		      glTexImage2D(3G)



     A one-component texture image uses	only the red component of the RGBA
     color extracted from pixels.  A two-component image uses the R and	A
     values.  A	three-component	image uses the R, G, and B values.  A four-
     component image uses all of the RGBA components.

     The mapping of components from the	canonical RGBA to the internal storage
     formats that begin	with GL_DUAL_ and GL_QUAD_ needs to be clarified.
     There are three cases.  The first case is for the GL_DUAL_	formats	that
     are groups	of GL_ALPHA, GL_LUMINANCE, and GL_INTENSITY.  The R value goes
     to	the first group	while the A value goes to the second group.  The
     second case is for	the GL_DUAL_ formats that are groups of
     GL_LUMINANCE_ALPHA.  The R	and G values go	to the first group while the B
     and A values go to	the second group.  The third case is for the GL_QUAD_
     formats.  The R value goes	to the first group, the	G value	to the second
     group, the	B value	to the third group, and	the A value to the fourth
     group.

     When components and format	have the value GL_DEPTH_COMPONENT,
     glTexImage2D defines a depth texture that can be used for shadow mapping.
     See glIntro and glTexParameter for	more information.

NOTES
     Texturing has no effect in	color index mode.

     glPixelStore and glPixelTransfer modes affect texture images in exactly
     the way they affect glDrawPixels.

     The proxy textures	and the	internal format	components symbolic values are
     part of the EXT_texture extension,	not part of the	core GL	command	set.
     If	GL_EXT_texture is included in the string returned by glGetString, when
     called with argument GL_EXTENSIONS, extension EXT_texture is supported by
     the GL.  Similarly, abgr is supported only	when the extensions string
     contains GL_EXT_abgr.

     If	type is	set to GL_UNSIGNED_BYTE_3_3_2_EXT,
     GL_UNSIGNED_SHORT_4_4_4_4_EXT, GL_UNSIGNED_SHORT_5_5_5_1_EXT,
     GL_UNSIGNED_INT_8_8_8_8_EXT, or GL_UNSIGNED_INT_10_10_10_2_EXT and	the
     EXT_packed_pixels extension is not	supported then a GL_INVALID_ENUM error
     is	generated.

     See glIntro for more information on using extensions.

ERRORS
     GL_INVALID_ENUM is	generated when target is not one of the	allowable
     values.

     GL_INVALID_ENUM is	generated when format is not an	accepted format.

     GL_INVALID_ENUM is	generated when type is not an accepted type.






									Page 5






glTexImage2D(3G)	       OpenGL Reference		      glTexImage2D(3G)



     GL_INVALID_ENUM is	generated if type is GL_BITMAP and format is not
     GL_COLOR_INDEX.

     GL_INVALID_VALUE is generated if level is less than zero

     GL_INVALID_VALUE is generated if components is not	1, 2, 3, or 4 or one
     of	the accepted symbolic constants.

     GL_INVALID_VALUE is generated if width or height is less than zero,
     greater than 2+GL_MAX_TEXTURE_SIZE, when width cannot be represented as
     2**k+2*border for some integer k, or when height cannot be	represented as
     2**k+I*border, where I is 2 when GL_INTERLACE_SGIX	is disabled and	1
     otherwise.

     GL_INVALID_VALUE is generated if border is	not 0 or 1.

     GL_INVALID_OPERATION is generated if glTexImage2D is executed between the
     execution of glBegin and the corresponding	execution of glEnd.

     GL_TEXTURE_TOO_LARGE_EXT is generated if the implementation cannot
     accomodate	a texture of the requested size.

     GL_INVALID_VALUE is generated if target is	GL_DETAIL_TEXTURE_2D_SGIS and
     level is not zero.

     GL_INVALID_VALUE is generated if target is	GL_DETAIL_TEXTURE_2D_SGIS and
     border is not zero.

ASSOCIATED GETS
     glGetTexImage
     glIsEnabled with argument GL_TEXTURE_2D
     glGetTexLevelParameter with a first argument of GL_PROXY_TEXTURE_2D_EXT
     and a third argument of GL_TEXTURE_RED_SIZE_EXT,
     GL_TEXTURE_GREEN_SIZE_EXT,	GL_TEXTURE_BLUE_SIZE_EXT,
     GL_TEXTURE_ALPHA_SIZE_EXT,	GL_TEXTURE_LUMINANCE_SIZE_EXT,
     GL_TEXTURE_INTENSITY_SIZE_EXT, GL_TEXTURE_WIDTH, GL_TEXTURE_HEIGHT,
     GL_TEXTURE_BORDER,	or GL_TEXTURE_COMPONENTS.



MACHINE	DEPENDENCIES
     RealityEngine, RealityEngine2, and	VTX systems do not support convolving
     images as they are	loaded into texture memory.

     InfiniteReality systems have limited support for convolving images	as
     they are loaded into texture memory.  The image resulting from
     convolution must be a multiple of 8 in width.

     On	RealityEngine, RealityEngine2, and VTX systems the width and height of
     a detail texture must both	be 256.	On High	Impact and Maximum Impact
     systems, detail texture size must be 128x128 or 256x256.




									Page 6






glTexImage2D(3G)	       OpenGL Reference		      glTexImage2D(3G)



     RealityEngine, RealityEngine2, and	VTX systems do not support histogram
     or	minmax operations on images as they are	being loaded into texture
     memory.

     The SGIX_interlace	extension is supported only on InfiniteReality systems
     and on RealityEngine, RealityEngine2, and VTX systems.

     The EXT_packed_pixels extension is	not supported on RealityEngine,
     RealityEngine2, and VTX systems; it will be supported on High Impact and
     Maximum Impact systems in a future	release.

     GL_DEPTH_COMPONENT	textures are a partial implementation of an extension
     that will be more fully documented	in a subsequent	release.  They are
     supported only on InfiniteReality systems.

     On	RealityEngine, RealityEngine2, and VTX systems:

	  1.  The texture environment must be defined and texturing must be
	      enabled before loading a texture.

	  2.  Texture formats composed only of alpha are not supported.

	  3.  Borders are not supported; hence the border width	must be	0.

	  4.  Proxy textures are not supported.

	  5.  glTexImage2D with	a NULL texture image may not be	used inside a
	      display list.

	  6.  GL_INTERLACE_SGIX	is not supported (see glEnable).

     High Impact and Maximum Impact systems do not support texture internal
     formats of	the type GL_INTENSITY or GL_ALPHA. Internally the number of
     bits per component	is the same for	all components and will	be 4, 8, or 12
     bits per component. All specified internal	formats	will receive an	equal
     or	greater	representation in this scheme, up to the 12-bit	limit.

     High Impact and Maximum Impact systems without the	TRAM option card
     support 4 bits per	component for GL_RGB and GL_RGBA, 4/8 bits per
     component for GL_LUMINANCE_ALPHA, and 4/8/12 bits per component for
     GL_RGBA.

     On	InfiniteReality	systems, defining 2D and 3D textures in	arbitrary
     order can cause incorrect results if texture memory is overcommitted.
     Workarounds are to	define all 3D textures before defining any 2D
     textures, or to ensure that the application never defines more textures
     than will fit in texture memory.  This will be fixed in the next release.

     Texture borders are not supported on InfiniteReality systems, so the
     border width should always	be zero.  Borders will be supported in future
     releases.	However, borders use texture memory very inefficiently;	up to
     four times	the memory required by the base	texture	may be needed to



									Page 7






glTexImage2D(3G)	       OpenGL Reference		      glTexImage2D(3G)



     support borders properly.	Whenever possible, applications	should use the
     texture wrap mode GL_CLAMP_TO_EDGE_SGIS and borderless textures.  This
     might be essential	for large textures, which otherwise won't fit in
     texture memory because of the border overhead.

     The SGIS_texture_select extension is supported only on InfiniteReality
     systems and on High Impact	and Maximum Impact systems with	the TRAM
     option card.


SEE ALSO
     glConvolutionFilter2DEXT, glDetailTexFuncSGIS, glDrawPixels, glFog,
     glEnable, glHistogramEXT, glMinmaxEXT, glPixelStore, glPixelTransfer,
     glSeparableFilter2DEXT, glTexEnv, glTexGen, glTexImage1D, glTexParameter.









































									Page 8